<template>
    <div>
        <el-tree ref="permisssionTree" show-checkbox node-key="menuId" :default-checked-keys="checkedMenuId" :default-expand-all="true" :data="data"
            :props="defaultProps" @node-click="handleNodeClick">
        </el-tree>
    </div>
</template>

<script>
    import axios from '../../util/request';
    export default {
        name: 'CodeUIAssignPermission',

        data() {
            return {
                data: [],
                defaultProps: {
                    children: 'children',
                    label: 'menuName'
                },
                checkedMenuId: []
            };
        },
        mounted() {

        },
        methods: {
            EditPermission(roleId) {
                axios.get('/api/menu').then(m => {
                    this.data = m.data;
                });
                axios.get(`/Role/QueryByRoleId?roleid=${roleId}`).then(m => {
                    this.checkedMenuId = m.data.data;
                });
            },
            handleNodeClick(a, b, c) {
                console.log(a, b, c);
            },
            SavePermission(){
                //console.log(1);
                //console.log(this.$refs.permisssionTree.getCheckedNodes(false,true));
                //console.log(this.$refs.permisssionTree.getCheckedKeys());
                //console.log(this.$refs.permisssionTree.getCheckedKeys(false));
                //console.log(this.$refs.permisssionTree.getCheckedKeys(true));
            }
        },
    };
</script>